# $Id: PKGBUILD 88838 2013-04-23 16:26:01Z tredaelli $
# Maintainer: Timothy Redaelli <timothy.redaelli@gmail.com>
# Contributor: helios
# Contributor: Lothar Gesslein
# Contributor: Dominik George <nik@naturalnet.de>

pkgname=tinc
pkgver=1.0.21
pkgrel=1
pkgdesc="VPN (Virtual Private Network) daemon"
arch=('i686' 'x86_64')
url="http://www.tinc-vpn.org/"
license=('GPL')
depends=('lzo2' 'openssl')
backup=(etc/conf.d/tincd.conf)
install=tinc.install
source=(http://www.tinc-vpn.org/packages/tinc-$pkgver.tar.gz{,.sig}
        tincd.rc tincd.conf tincd@.service)
md5sums=('d7bc9ca38672c9da08d74ff2a3e8e36d'
         'SKIP'
         '64bb53748d9051255f243003f0d511f5'
         '7c0276d4812cc5d3cc18142562a3aa82'
         '035b0e549b08da55d19a8df5b8306e4d')

build() {
  cd "$srcdir/$pkgname-$pkgver"

  ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
  make
}

package() {
  cd "$srcdir/$pkgname-$pkgver"

  make DESTDIR="$pkgdir/" install
  install -dm755 "$pkgdir"/usr/share/tinc/examples
  tar xozvf doc/sample-config.tar.gz -C $pkgdir/usr/share/tinc/examples
  find "$pkgdir"/usr/share/tinc/examples -type f -exec chmod 644 {} +
  find "$pkgdir"/usr/share/tinc/examples -type d -exec chmod 755 {} +

  install -Dm755 "$srcdir/tincd.rc" "$pkgdir/etc/rc.d/tincd"
  install -Dm644 "$srcdir/tincd.conf" "$pkgdir/etc/conf.d/tincd.conf"
  install -Dm644 "$srcdir/tincd@.service" "$pkgdir/usr/lib/systemd/system/tincd@.service"
}
